home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DDJ0192.ARJ / CLIPBORD.C < prev    next >
Text File  |  1991-11-07  |  1KB  |  38 lines

  1. /* ----------- clipbord.c ------------ */
  2. #include "dflat.h"
  3.  
  4. char *Clipboard;
  5. int ClipboardLength;
  6.  
  7. void CopyToClipboard(WINDOW wnd)
  8. {
  9.     if (TextBlockMarked(wnd))    {
  10.         char *bbl=TextLine(wnd,wnd->BlkBegLine)+wnd->BlkBegCol;
  11.         char *bel=TextLine(wnd,wnd->BlkEndLine)+wnd->BlkEndCol;
  12.         int len = (int) (bel - bbl);
  13.         ClipboardLength = len;
  14.         Clipboard = realloc(Clipboard, ClipboardLength);
  15.         if (Clipboard != NULL)
  16.             memmove(Clipboard, bbl, ClipboardLength);
  17.     }
  18. }
  19.  
  20. void PasteText(WINDOW wnd, char *SaveTo, int len)
  21. {
  22.     if (SaveTo != NULL && len > 0)    {
  23.         int plen = strlen(wnd->text) + len;
  24.         char *bl, *el;
  25.  
  26.         if (plen > wnd->textlen)    {
  27.             wnd->text = realloc(wnd->text, plen+2);
  28.             wnd->textlen = plen;
  29.         }
  30.         bl = CurrChar;
  31.         el = bl+len;
  32.         memmove(el,    bl,    strlen(bl)+1);
  33.         memmove(bl, SaveTo, len);
  34.         BuildTextPointers(wnd);
  35.         wnd->TextChanged = TRUE;
  36.     }
  37. }
  38.